package com.edu.exam.entity.examination.paper.technical;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import jakarta.persistence.*;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;

import java.time.LocalDateTime;

/**
 * 质量评估实体类
 *
 * 根据E-04-02图像处理子模块数据库设计实现
 * 存储图像质量评估的详细信息。
 *
 * @author System
 * @version 2.0.0
 * @since 2025-11-15
 */

@Entity
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
public class ImageProcessingQualityAssessment {

    /**
     * 评估ID，主键
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    private Long id;

    /**
     * 评估标识
     */
    @Column(name = "assessment_id", length = 64, unique = true)
    private String assessmentId;

    /**
     * 图像ID
     */
    @Column(name = "image_id", length = 64, nullable = false)
    private String imageId;

    /**
     * 评估类型
     */
    @Column(name = "assessment_type", length = 30, nullable = false)
    private String assessmentType;

    /**
     * 评估版本
     */
    @Column(name = "assessment_version", length = 10, nullable = false)
    private String assessmentVersion;

    /**
     * 总体评分
     */
    @Column(name = "overall_score", precision = 5, scale = 2, nullable = false)
    private Double overallScore;

    /**
     * 质量等级
     */
    @Column(name = "quality_grade", length = 10, nullable = false)
    private String qualityGrade;

    /**
     * 是否可接受
     */
    @Column(name = "is_acceptable", nullable = false)
    private Boolean isAcceptable;

    /**
     * 评估时间
     */
    @Column(name = "assessment_time", nullable = false)
    private LocalDateTime assessmentTime;

    /**
     * 评估器类型
     */
    @Column(name = "assessor_type", length = 20, nullable = false)
    private String assessorType;

    // 分辨率指标

    /**
     * 分辨率评分
     */
    @Column(name = "resolution_score", precision = 5, scale = 2)
    private Double resolutionScore;

    /**
     * 实际DPI
     */
    @Column(name = "actual_dpi", precision = 5, scale = 1)
    private Double actualDpi;

    /**
     * 分辨率等级
     */
    @Column(name = "resolution_grade", length = 10)
    private String resolutionGrade;

    // 清晰度指标

    /**
     * 清晰度评分
     */
    @Column(name = "clarity_score", precision = 5, scale = 2)
    private Double clarityScore;

    /**
     * 锐度值
     */
    @Column(name = "sharpness_value", precision = 10, scale = 4)
    private Double sharpnessValue;

    /**
     * 清晰度等级
     */
    @Column(name = "clarity_grade", length = 10)
    private String clarityGrade;

    // 完整性指标

    /**
     * 完整性评分
     */
    @Column(name = "completeness_score", precision = 5, scale = 2)
    private Double completenessScore;

    /**
     * 缺失内容比例
     */
    @Column(name = "missing_content_rate", precision = 5, scale = 2)
    private Double missingContentRate;

    /**
     * 完整性等级
     */
    @Column(name = "completeness_grade", length = 10)
    private String completenessGrade;

    // 噪声指标

    /**
     * 噪声评分
     */
    @Column(name = "noise_score", precision = 5, scale = 2)
    private Double noiseScore;

    /**
     * 噪声水平
     */
    @Column(name = "noise_level", precision = 5, scale = 2)
    private Double noiseLevel;

    /**
     * 噪声类型
     */
    @Column(name = "noise_type", length = 30)
    private String noiseType;

    // 其他指标

    /**
     * 对比度评分
     */
    @Column(name = "contrast_score", precision = 5, scale = 2)
    private Double contrastScore;

    /**
     * 亮度评分
     */
    @Column(name = "brightness_score", precision = 5, scale = 2)
    private Double brightnessScore;

    /**
     * 色彩平衡评分
     */
    @Column(name = "color_balance_score", precision = 5, scale = 2)
    private Double colorBalanceScore;

    /**
     * 评估配置
     */
    @Column(name = "assessment_config", columnDefinition = "TEXT")
    private String assessmentConfig;

    /**
     * 异常检测结果
     */
    @Column(name = "anomaly_detection_result", columnDefinition = "TEXT")
    private String anomalyDetectionResult;

    /**
     * 改进建议
     */
    @Column(name = "improvement_suggestions", columnDefinition = "TEXT")
    private String improvementSuggestions;

    // 审计字段

    /**
     * 创建时间
     */
    @CreationTimestamp
    @Column(name = "created_time", nullable = false, updatable = false)
    private LocalDateTime createdTime;

    /**
     * 更新时间
     */
    @UpdateTimestamp
    @Column(name = "updated_time", nullable = false)
    private LocalDateTime updatedTime;

    /**
     * 创建人
     */
    @Column(name = "created_by", length = 64)
    private String createdBy;

    /**
     * 更新人
     */
    @Column(name = "updated_by", length = 64)
    private String updatedBy;

    /**
     * 版本号（乐观锁）
     */
    @Version
    @Column(name = "version")
    private Integer version = 0;

    /**
     * 逻辑删除标记
     */
    @Column(name = "is_deleted", nullable = false)
    private Boolean isDeleted = false;
}